package routers

import (
	"beego-demo/controllers"
	"beego-demo/controllers/admin"
	"beego-demo/controllers/login"
	beego "github.com/beego/beego/v2/server/web"
)

// restful Api定义
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &admin.LoginController{}, "get,post:Login")
	beego.Router("/admin", &admin.UserController{})
	beego.Router("/admin/:username/:password", &admin.UserController{}, "post:Post")
	beego.Router("/admin/checkUserinfo", &admin.UserController{}, "put:CheckUserInfo")
	beego.Router("/admin/checkUserinfoJson", &admin.UserController{}, "delete:CheckUserInfoJson")

	beego.Router("/admin/addSysUser", &admin.UserController{}, "post:AddSysUser")
	beego.Router("/admin/removeUserById/:id", &admin.UserController{}, "delete:RemoveSysUser")
	beego.Router("/admin/updateSysUser", &admin.UserController{}, "post:UpdateSysUser")
	beego.Router("/admin/getUserById/:id", &admin.UserController{}, "get:GetUserById")
	beego.Router("/admin/getUserList", &admin.UserController{}, "get:GetUserList")

	//多种请求对应一个方法
	beego.Router("/api/multi", &login.RestController{}, "get,post:ApiFunc")

	//beego.Router("/api/food",&controllers.RestController{},"get:ListFood;")
	//beego.Router("/api/food",&controllers.RestController{},"post:CreateFood")
	//beego.Router("/api/food",&controllers.RestController{},"put:UpdateFood")
	//beego.Router("/api/food",&controllers.RestController{},"delete:DeleteFood")
	beego.Router("/api/food", &login.RestController{}, "get:ListFood;post:CreateFood;put:UpdateFood;delete:DeleteFood")
}
